package cn.zwx.goods.svc.service.impl;

import cn.zwx.goods.svc.domain.bo.BrandBO;
import cn.zwx.goods.svc.domain.entity.BrandEntity;
import cn.zwx.goods.svc.domain.enums.DelFlag;
import cn.zwx.goods.svc.mapper.BrandMapper;
import cn.zwx.goods.svc.service.BrandService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author zhangwenxuye
 */
@Service
public class BrandServiceImpl  implements BrandService {

    @Resource
    private BrandMapper brandMapper;


    @Override
    public Integer selectCount(LambdaQueryWrapper<BrandEntity> queryWrapper) {
        return brandMapper.selectCount(queryWrapper).intValue();
    }

    @Override
    public List<BrandEntity> selectList(BrandBO brandBO) {
        return brandMapper.selectList(brandBO);
    }

    @Override
    public BrandEntity selectById(Integer brandId) {
        return brandMapper.selectById(brandId);
    }

    @Override
    public int insert(BrandEntity brandEntity) {
        return brandMapper.insertSelective(brandEntity);
    }

    @Override
    public int delete(Integer brandId) {
        final BrandEntity brandEntity = new BrandEntity();
        brandEntity.setId(brandId);
        brandEntity.setUpdateTime(new Date());
        brandEntity.setDelFlag(DelFlag.delete.getCode());
        return brandMapper.updateByPrimaryKeySelective(brandEntity);
    }

    @Override
    public int update(BrandEntity modify) {
        return brandMapper.updateByPrimaryKeySelective(modify);
    }
}
